umask
A light utility helping with unix mode representation, with strong types to avoid misusing constants.
The Mode struct implements Display
and prints as "rwxrwxrwx"
Import
In Cargo.toml:
umask = "'2.0"
Usage
use *;
// You can build from a number:
assert_eq!;
assert_eq!;
// You may use `|` to combine class permissions:
let mu = from;
let mo = from;
assert_eq!;
assert_eq!;
// You can use more semantic constructs:
let m = all
.without;
assert_eq!;
let mut m = new
.with_class_perm
.with_class_perm;
assert_eq!;
// (semantic functions can be used in const declarations)
// Or
m |= ALL_EXEC;
assert_eq!;
let m = ALL_READ | USER_WRITE;
assert_eq!;
// Displaying the mode can be done with the `Display`
// implementation but also bit per bit for more control
assert_eq!;
// The `Display` implementation shows the extra permission bits
// (setuid, setgid and sticky):
let mut m = all
.with_extra
.with_extra
.with_extra;
assert_eq!;
// But you can remove those bits for display if you want the
// sometimes more familiar 'x' for execution:
assert_eq!;